package cn.wolfcode.service;

import cn.wolfcode.domain.OperateIntergralVo;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;


@LocalTCC
public interface IUsableIntegralService {

    /**
     * 积分支付 减积分
     * @param operateIntergralVo
     */
    void payIntergral(OperateIntergralVo operateIntergralVo);

    /**
     * 积分退款 加积分
     * @param operateIntergralVo
     */
    void refundIntergral(OperateIntergralVo operateIntergralVo);

    /**
     * 增加积分
     */
    @TwoPhaseBusinessAction(name = "incrIntergralTry", commitMethod = "incrIntergralCommit", rollbackMethod = "incrIntergralRollback")
    void incrIntergralTry(@BusinessActionContextParameter(paramName = "operateIntergralVo") OperateIntergralVo operateIntergralVo, //@BusinessActionContextParameter注解 将第一个参数放到上下文对象当中
                          BusinessActionContext context);

    void incrIntergralCommit(BusinessActionContext context);

    void incrIntergralRollback(BusinessActionContext context);
}
